﻿
<?php
if (!defined('WEB_ROOT')) {
	exit;
}

// make sure id exists
if (isset($_GET['id']) && $_GET['id'] > 0) {
	$id = (int)$_GET['id'];
} else {
	// redirect to index.php 
	header('Location: index.php');
}
if (isset($_GET['dv_id']) && $_GET['dv_id'] > 0) {
	$dv_id = (int)$_GET['dv_id'];
}
// Lấy thông tin nhóm ngành
$sql = "SELECT nn.id, nn.mann, nn.tennn, nn.dv_id
        FROM nhomnganh nn
		WHERE nn.id = $id";
	$result = mysql_query($sql) or die('Cannot get topic group. ' . mysql_error());
	$row    = mysql_fetch_assoc($result);
	extract($row);
	
	$sql = "SELECT id, tendv
				FROM donvi
				ORDER BY id";
		$result = dbQuery($sql) or die('Không lấy được thông tin đơn vị. ' . mysql_error());
		
		$groups = array();
		$list = '';
		while($row = dbFetchArray($result)) {
			list($id_dv, $name) = $row;
			$list .= "<option value=\"$id_dv\"";
				if ($id_dv == $dv_id) {
					$list.= " selected";
				}
				$list .= ">$name</option>\r\n";
		}	
?> 
<div class="onecolumn">
				<div class="header">
					<span>Sửa thông tin nhóm ngành</span>
				</div>
				<br class="clear"/>
				<div class="content">
<form action="processTopicGroup.php?action=modify&id=<?php echo $id; ?>&dv_id=<?php echo $dv_id; ?>" method="post" enctype="multipart/form-data" name="frmAddTopicGroup" id="frmAddTopicGroup">
 <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">

  <tr> 
	   <td width="150" class="label">Mã nhóm ngành</td>
	   <td class="content"> <input name="txtMann" type="text" class="box" id="txtMann" readonly="true" style="background-color:#DADADA" value="<?php echo $mann; ?>"  size="20" maxlength="20"></td>
  </tr>
  <tr> 
	   <td width="150" class="label">Tên nhóm ngành</td>
	   <td class="content"> <input name="txtTennn" type="text" class="box" id="txtTennn" value="<?php echo $tennn; ?>"  size="40" maxlength="40"></td>
  </tr>
  <tr> 
	   <td width="150" class="label">Đơn vị</td>
	   <td class="content"> <select name="cboDept" id="cboDept" class="box">
		 <option value="" selected>-- Chọn đơn vị --</option>
		<?php
			echo $list;
		?>	 
		</select></td>
  </tr>    
 </table>
 <p align="center"> 
  <input name="btnModifyTopicGroup" type="button" id="btnModifyTopicGroup" value="Lưu thay đổi" onClick="checkAddTopicGroupForm();" class="box">
  &nbsp;&nbsp;<input name="btnCancel" type="button" id="btnCancel" value="  Hủy  " onClick="window.location.href='index.php';" class="box">  
 </p>
</form>
</div></div>